Skip to content

feat: add agent-describe protocol for self-describing CLIs#33

Merged
crrow merged 9 commits intomainfrom
feat/agent-describe
Mar 27, 2026
Merged

feat: add agent-describe protocol for self-describing CLIs#33
crrow merged 9 commits intomainfrom
feat/agent-describe

Conversation

@crrow
Copy link
Copy Markdown
Contributor

@crrow crrow commented Mar 27, 2026

Summary

  • Add agent-describe and agent-describe-derive crates as workspace members under crates/
  • Template-generated CLIs now support --agent-describe flag that outputs a JSON schema following the agent-cli/1 protocol
  • Replace ad-hoc serde_json::json!() output with typed AgentResponse<T> wrapper
  • Naming convention: command variant FooFooResult struct for output schema (auto-derived via proc macro)

What this enables

Any AI agent encountering a CLI built from this template can:

  1. Run mycli --agent-describe to discover all commands, args, and output schemas
  2. Call commands and parse typed JSON responses
  3. Self-correct on errors using the suggestion field

No MCP server needed — just spawn + parse.

Changes

  • New crates: crates/agent-describe (runtime) + crates/agent-describe-derive (proc macro)
  • Template updates: cli/mod.rs gets AgentDescribe derive, main.rs uses AgentResponse, new response.rs with typed result structs
  • Docs: CLAUDE.md, README.md updated with agent-cli/1 protocol docs
  • Release: release-plz configured to publish both lib crates to crates.io
  • Tests: 12 tests passing across workspace (8 crate tests + 4 template tests)

Test plan

  • cargo check --workspace passes
  • cargo test --workspace — 12 tests pass
  • Generate project → cargo run -- --agent-describe outputs valid schema
  • Generate project → cargo run -- hello outputs AgentResponse format
  • Generate project → cargo test — all 7 integration tests pass
  • CI green

🤖 Generated with Claude Code

crrow and others added 9 commits March 27, 2026 10:32
- Add agent-describe (path dep) and schemars to template/Cargo.toml
- Create template/src/response.rs with result types for all commands
- Export response module from template/src/lib.rs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ponses

- Add AgentDescribe derive and #[agent(cli = Cli)] to Command enum
- Add hidden --agent-describe flag to Cli struct
- Replace all ad-hoc serde_json::json!() output with typed AgentResponse<T>
- Wire #[agent(output = ...)] annotations for Hello and Agent variants

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add agent-describe and agent-describe-derive under crates/ as workspace
members. Configure release-plz to publish the library crates while
keeping the binary crate unpublished. Update template/Cargo.toml to use
a version dependency instead of an absolute path.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@crrow crrow merged commit 1da3ec8 into main Mar 27, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant